var _Step = require('scenes/game/toturial/step.js');
var _inherit = require('core/inherit.js');
var _global = require('global/global.js');

function Step() {
    _Step.call(this);
    this.mFinish = false;
}
_inherit(Step, _Step);
Step.prototype.onAbsorbStart = function (accept) {
    if (accept && !this.mFinish) {
        this.mCells.checkMerge(this.mGameArea.getPredict(), this);
    }
};
Step.prototype.onMergeBefore = function () {
    if (this.mFinish) {
        this.mToturial.hideHeader();
        this.mToturial.hideFooter();

        this.mToturial.nextStep();
        this.mToturial = null;
        this.mLocal = null;
    }
};
Step.prototype.onMergeFind = function (index, count) {
    if (count >= 12) {
        this.mFinish = true;
    }
};
Step.prototype.onStart = function (toturial, local) {
    this.mToturial = toturial;
    this.mLocal = local;

    toturial.showFooterTip('CREATE A 12 TO CONTINUE');
    this.mLocal.find('gamearea.slotpool').addSlots([3, 3, 3, 3], true);// ensure there is enough cells

    this.mCells = this.mLocal.find('gamearea.cells');
    this.mGameArea = this.mLocal.find('gamearea');
};

module.exports = Step;